package com.optitronics.validators;

import java.util.Properties;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.support.WebBindingInitializer;
import org.springframework.web.context.request.WebRequest;

import com.optitronics.util.OptitronicsStringEditor;

@Component("optitronicsBindingInitializer")
public class OptitronicsBindingInitializer implements WebBindingInitializer {

	@Autowired
	@Qualifier("charsToReplace")
	private Properties charsToReplace;

	public void initBinder(WebDataBinder binder, WebRequest request) {

		binder.registerCustomEditor(String.class, new OptitronicsStringEditor(true, charsToReplace));
	}
}
